#ifndef __GAME_MACROS_H__
#define __GAME_MACROS_H__

#include <functional>
#include <assert.h>
#include "game_log.h"

#if CGAME_DEBUG > 0
#define C_ASSERT(cond, msg) if(!(cond)){__fatal("Assert failed: %s", msg);assert(cond);}
#define CC_ASSERT(cond,name,msg) if(!(cond)){__ccfatal(name,"Assert failed: %s", msg);assert(cond);}
#else
#define C_ASSERT(cond, msg) 
#define CC_ASSERT(cond,name,msg)
#endif

#define CC_GOTO_IF(cond,too)                        if(cond) goto too;

#define CC_BREAK_IF(cond)					                  if(cond) break
#define CC_BREAK_IF_LOG(cond,format,...)            if(cond) {C_LOG(format,##__VA_ARGS__);break;}
#define CC_BREAK_IF_WAR(cond,logger,format,...)     if(cond) {logger->warn(format,##__VA_ARGS__);break;}

#define CC_CONTINUE_IF(cond)					              if(cond) continue;

// new callbacks based on C++11
#define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__)
#define CC_CALLBACK_1(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, ##__VA_ARGS__)
#define CC_CALLBACK_2(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS__)
#define CC_CALLBACK_3(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, ##__VA_ARGS__)


#endif
